home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac100% 1998 November
/
MAC100-1998-11.ISO.7z
/
MAC100-1998-11.ISO
/
オンラインソフト定点観測
/
ユーティリティ
/
Mops 3.2.sea
/
Mops 3.2
/
Mops source
/
PPC source
/
test2
< prev
next >
Wrap
Text File
|
1998-04-20
|
3KB
|
137 lines
¥ expint Real Exponential Integral ACM Algorithm #20
¥ Forth Scientific Library Algorithm #1
¥ Evaluates the Real Exponential Integral,
¥ E1(x) = - Ei(-x) = int_x^¥infty exp^{-u}/u du for x > 0
¥ using a rational approximation
¥ This code conforms with ANS requiring:
¥ 1. The Floating-Point word set
¥ 2. The immediate word '%' which takes the next token
¥ and converts it to a floating-point literal
¥
¥ Collected Algorithms from ACM, Volume 1 Algorithms 1-220,
¥ 1980; Association for Computing Machinery Inc., New York,
¥ ISBN 0-89791-017-6
¥ (c) Copyright 1994 Everett F. Carter. Permission is granted by the
¥ author to use this software for any application provided the
¥ copyright notice is preserved.
CR .( EXPINT V1.1 21 September 1994 EFC )
variable v1
variable v2
variable v3
variable v4
variable v5
variable v6
variable v7
variable v11
variable v12
variable v13
variable v14
variable v15
variable v16
variable v17
variable v18
variable v21
variable v22
variable v23
variable v24
variable v25
variable v26
variable v27
variable v28
: expint ( --, f: x -- expint[x] )
FDUP
(* % 1.0 F< IF
FDUP % 0.00107857 F* % 0.00976004 F-
FOVER F*
% 0.05519968 F+
FOVER F*
% 0.24991055 F-
FOVER F*
% 0.99999193 F+
FOVER F*
% 0.57721566 F-
FSWAP FLN F-
ELSE
*)
FDUP v4 f@ F+
FOVER F*
v5 f@ F+
FOVER F*
v6 f@ F+
db
FOVER F*
v7 f@ F+
(* v11 f@
v12 f@
v13 f@
v14 f@
v15 f@
v16 f@
v17 f@
v18 f@
v21 f@
v22 f@
v23 f@
v24 f@
v25 f@
v26 f@
v27 f@
v28 f@
*)
FOVER
FDUP v1 f@ F+
FOVER F*
v2 f@ F+
FOVER F*
v3 f@ F+
FOVER F*
% 3.9584969228 F+
FSWAP FDROP
F/
FOVER F/
FSWAP % -1.0 F* FEXP
F*
¥ THEN
;
¥ test code generates a small table of selected E1 values.
¥ most comparison values are from Abramowitz & Stegun,
¥ Handbook of Mathematical Functions, Table 5.1
: expint_test ( -- )
CR
." x E1(x) exact ExpInt[x] " CR
." 0.5 0.5597736 "
% 0.5 expint F. CR
." 1.0 0.2193839 "
% 1.0 expint F. CR
." 2.0 0.0489005 "
% 2.0 expint F. CR
." 5.0 0.001148296 "
% 5.0 expint F. CR
." 10.0 0.4156969e-5 "
% 10.0 expint F. CR
;